﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestCodePage
{
    class Program
    {
        static void Main(string[] args)
        {
            string target = "¿µÁØ (ºê¶ó¿î ¾ÆÀÌµå ¼Ò¿ï); ";
            byte[] targetBytes = Encoding.ASCII.GetBytes(target);

            //foreach (EncodingInfo enc in Encoding.GetEncodings())
            //{
                
            //    Console.WriteLine("{0, 6}, {1}",
            //        enc.CodePage, 
            //        enc.DisplayName);

            //    byte[] dstBytes = Encoding.Convert(Encoding.Default, enc.GetEncoding(), targetBytes);

            //    Console.WriteLine("{0, 6}, {1}, {2}",
            //        enc.CodePage,
            //        enc.DisplayName,
            //        Encoding.Default.GetString(dstBytes)
            //        );
            //}

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\temp\\ec.txt"))
            {
                sw.AutoFlush = true;
                foreach (EncodingInfo enc in Encoding.GetEncodings())
                {
                    byte[] dstBytes = Encoding.Convert(Encoding.ASCII, enc.GetEncoding(), targetBytes);

                    sw.WriteLine("{0, 6}, {1}, {2}",
                        enc.CodePage,
                        enc.DisplayName,
                        Encoding.GetEncoding(949).GetString(Encoding.GetEncoding(1252).GetBytes(target))
                        //Encoding.Unicode.GetString(dstBytes)
                        //enc.GetString(dstBytes)
                        );
                }
            }
            

            ////byte[] srcBytes = Encoding.Default.GetBytes("À¯¸®»óÀÚ; ");
            //Encoding srcEncoding = Encoding.GetEncoding(50225);
            //byte[] srcBytes = srcEncoding.GetBytes("À¯¸®»óÀÚ; ");
            ////Encoding e = Encoding.UTF8

            //byte[] dstBytes = Encoding.Convert(
            //    srcEncoding,
            //    Encoding.UTF8, 
            //    srcBytes);

            //string dst = Encoding.UTF8.GetString(dstBytes);

            //Console.WriteLine(dst);
            //Console.WriteLine(e.BodyName);
            
            //Console.ReadLine();
        }
    }
}
